package com.bytedance.controller;

import com.bytedance.dataobject.A;
import com.bytedance.model.Result;
import com.bytedance.service.AService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/A")
public class AController {

    @Autowired
    private AService aService;

    @PostMapping
    public Result<A> add(@RequestBody A a) {
        return aService.add(a);
    }

    @PostMapping("/addList")
    public Result<List<A>> addList(@RequestBody List<A> aList) {
        return aService.add(aList);
    }

    @PutMapping
    public Result<A> update(@RequestBody A a) throws Exception {
        return aService.update(a);
    }

    @DeleteMapping("{id}")
    public Result<Integer> delete(@PathVariable String id) {
        return aService.delete(id);
    }

    @GetMapping("{id}")
    public Result<List<A>> get(@PathVariable String id) {
        return aService.getLike(id);
    }
}
